package com.example.admin.goodnews.database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

/**
 * 新建数据库，用于存放新闻分类以供搜索
 * Created by admin on 2016/10/13.
 */
public class MyDBHelper extends SQLiteOpenHelper {
    // 类没有实例化,是不能用作父类构造器的参数,必须声明为静态
    private static final String name = "newsclass.db"; // 数据库名称 新闻分类
    private static final int version = 1; // 数据库版本
    private Context context;

//    public MyDBHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
//        super(context, name, factory, version);
//    }

    public MyDBHelper(Context context) {
        super(context, "newsclass.db", null, 1);
    }

//    public MyDBHelper(Context context, String name, SQLiteDatabase.CursorFactory factory,
//                      int version) {
//        super(context, name, null, version);
//    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("CREATE TABLE IF NOT EXISTS newsclass (id integer primary key autoincrement, name varchar(40), date INTEGER)");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
